import { useParams } from 'react-router'

import { createPopupSlot } from '@/services/popupSlot'
import { EventEmitter } from '@/utils/eventEmitter'

export type TEventArgsMap = {
  /** 转单号变更，如录入转单号弹窗操作成功 */
  ['transferOrderNumChanged']: []
  /** 附件变更，如：发布路由所上传的附件、留言所上传/删除的附件 */
  ['attachmentChanged']: []
}
export const eventBus = new EventEmitter<TEventArgsMap>()

export const popupSlot = createPopupSlot()

export const useUrlParams = () => {
  const waybillNo = useParams().waybillNo || ''
  return {
    /** 运单号 */
    waybillNo,
  }
}

export const COMMENT_ID = 'comment'
